﻿@model AexoManager.Models.DespieceViewModel
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Template.cshtml";
}
@section ClientScripts {
    <script type='text/javascript'>
        $(function () {
            $("#btnNuevo").click(function () {
                $("#formPrincipal").submit();
            });

            $("#btnModificar").click(function () {
                $("#IdProducto").val($("#tblPartes .active").children("td:eq(0)").text());
                $("#formPrincipal").attr("action", "@Url.Content("~/")Despiece/ModificarProducto");
                $("#formPrincipal").submit();
            });

            $("#btnDespiece").click(function () {
                $("#IdProducto").val($("#tblPartes .active").children("td:eq(0)").text());
                $("#formPrincipal").attr("action", "@Url.Content("~/")Despiece/Arbol");
                $("#formPrincipal").submit();
            });

            $("#btnEliminar").click(function () {
                if (confirm("Desea eliminar el registro seleccionado?")) {
                    $("#IdProducto").val($("#tblPartes .active").children("td:eq(0)").text());
                    $("#formPrincipal").attr("action", "@Url.Content("~/")Despiece/Eliminar");
                    $("#formPrincipal").submit();
                }
            });

            $('#tblPartes').dataTable({
                "sDom": "<'row'<'col-sm-12'T><'col-sm-12'f>r>t<'row'<'col-sm-12'i><'col-sm-12'p>>",
                "bServerSide": false,
                "bAutoWidth": false,
                "bDestroy": true,
                "oTableTools": {
                    "sRowSelect": "single",
                    "aButtons": [
                    ]
                }
            });

            $('.dataTables_filter input').addClass('form-control').attr('style', 'display:none');
            $('.dataTables_length select').addClass('form-control');

        });
    </script>
}
<h2>Index</h2>
<div id="page-content">
    <div id='wrap'>
        <div id="page-heading">
            <ol class="breadcrumb">
                <li class='active'><a href="@Url.Content("~/")">Despiece</a></li>
                <li class='active'><a href="@Url.Content("~/")">Index</a></li>
            </ol>

            <h1>Productos</h1>
        </div>
        <div class="container">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h4>Productos</h4>
                </div>
                @using (Html.BeginForm("NuevoProducto", "Despiece", FormMethod.Post, new { @id = "formPrincipal", @class = "form-horizontal" }))
                {

                    <div class="panel-body collapse in">
                        <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered datatables  DTTT_selectable" id="tblPartes">
                            <thead>
                                <tr>
                                    <th width="10%">IdProducto</th>
                                    <th width="20%">Codigo</th>
                                    <th width="60%">Descripcion</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach (var item in ViewBag.Productos)
                                {
                                    <tr>
                                        <td>@item.IdProducto</td>
                                        <td>@item.Codigo</td>
                                        <td>@item.Descripcion</td>
                                    </tr>
                                }
                            </tbody>
                        </table>
                        <!--end table-->
                    </div>
                    @Html.HiddenFor(model => model.IdProducto)

                }
                <div class="panel-footer">
                    <div class="row">
                        <div class="pull-right">
                            <div class="btn-toolbar">
                                <button id="btnNuevo" class="btn-primary btn">Nuevo</button>
                                <button id="btnModificar" class="btn-primary btn">Modificar</button>
                                <button id="btnDespiece" class="btn-primary btn">Despiece</button>
                                <button id="btnEliminar" class="btn-primary btn">Eliminar</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <!-- container -->
    </div>
    <!--wrap -->
</div>
<!-- page-content -->